package de.slothsoft.commons.swing;

import java.util.ArrayList;
import java.util.List;

import javax.swing.AbstractListModel;

public class ListModel<T> extends AbstractListModel<T> {

	private static final long serialVersionUID = 1L;

	protected List<T> list;

	public ListModel() {
		this(new ArrayList<T>());
	}

	public ListModel(List<T> list) {
		assert list != null;
		this.list = list;
	}

	public List<T> getList() {
		return this.list;
	}

	@Override
	public T getElementAt(int index) {
		return this.list.get(index);
	}

	@Override
	public int getSize() {
		return this.list.size();
	}

	public void fireContentsChanged(int from, int to) {
		super.fireContentsChanged(this, from, to);
	}

	public void fireIntervalAdded(int from, int to) {
		super.fireIntervalAdded(this, from, to);
	}

	public void fireIntervalRemoved(int from, int to) {
		super.fireIntervalRemoved(this, from, to);
	}
}
